package com.lzt.admin.system.service.impl;

import com.lzt.admin.common.vo.UserDetailsVO;
import com.lzt.admin.system.dao.UserDAO;
import com.lzt.admin.vo.user.UserVO;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class UserDetailsServiceImpl implements UserDetailsService {
    private final UserDAO userDAO;
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        UserVO user = userDAO.getUserByName(username);
        return new UserDetailsVO(user);
    }
}
